<h1>New task</h1>

<% form_for(@task) do |f| %>
  <%= f.error_messages %>
  <%= f.hidden_field  :user_id %>
  <%= stylesheet_link_tag("calendar") %>
  <p>
    <%= f.label :patient_id %><br />
	  <div>
    <input type="text" id="autocomplete" name="search[name]"/>
    <div id="autocomplete_choices" class="autocomplete"></div>
	<%= f.hidden_field :patient_id %>
  </div>
  <script type="text/javascript">
    new Ajax.Autocompleter("autocomplete", "autocomplete_choices", "/tasks/autocomplete", {afterUpdateElement : function(text,li) { $('task_patient_id').value = li.id } });
  </script>
  </p>
  <p>
    <%= f.label :date %><br />
    <%= f.datetime_select :date, :order => [:day,:month,:year] %>
  </p>
  <p>
    <%= f.label :label %><br />
    <%= f.text_field :label %>
  </p>
  <p>
    <%= f.label :content %><br />
    <%= f.text_field :content %>
  </p>
  <p>
    <%= f.submit 'Create' %>
  </p>
<% end %>

<%= link_to 'Back', tasks_path %>